package com.zhongyouyun.lbyc.controller;


import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zhongyouyun.admin.model.UserModel;
import com.zhongyouyun.admin.service.UserService;
import com.zhongyouyun.lbyc.model.CustomReputationLevelModel;
import com.zhongyouyun.lbyc.pojo.CustomReputationLevelPojo;
import com.zhongyouyun.lbyc.pojo.WexinUserPogo;
import com.zhongyouyun.other.model.PageRequest;
import com.zhongyouyun.other.model.Result;
import com.zhongyouyun.utils.ModelUtils;
import com.zhongyouyun.utils.QueryUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.zhongyouyun.lbyc.service.WexinUserService;

import java.util.ArrayList;
import java.util.List;


/**
 * @Author: shenyi
 * @Date: 2023-11-14
 * @Description: 用户微信信息
 */
@RestController
@RequestMapping("/lbyc/lbyc_wexin_user")
@Api(value = "烟草灵宝-小程序用户controller", tags = {"烟草灵宝-评价接口"})
public class WexinUserController {
    @Autowired
    private WexinUserService service;
    @Autowired
    private UserService userService;
    @PostMapping("/findPage")
    @ResponseBody
    @ApiOperation(value = "小程序用户列表", notes = "获取小程序用户列表")
    public IPage<WexinUserPogo> findPage(@ApiParam(required = true) @RequestBody PageRequest pageRequest) {
        QueryWrapper<WexinUserPogo> queryWrapper = new QueryWrapper();
        QueryUtils.fiterQuery(queryWrapper, pageRequest);
        Page page = new Page(pageRequest.getPageNum(), pageRequest.getPageSize());
        return service.selectPojoPage(page, queryWrapper);
    }
    @GetMapping("/delete")
    @ResponseBody
    @ApiOperation(value = "解除绑定", notes = "通过ID解除绑定")
    public Result delete(@ApiParam(name = "ID", value = "id", required = true) @RequestParam(value = "id") String id) {
        Boolean flag = false;
        QueryWrapper queryWrapper=new QueryWrapper();
        queryWrapper.eq("user_id",id);
        flag = service.remove(queryWrapper);
        if (flag) {
            return Result.builder().message("成功").status(0).build();
        } else {
            return Result.builder().message("删除失败").success(false).status(1).build();
        }
    }
}
